package com.example.himalayaproject.subscription.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.example.himalayaproject.R;
import com.example.himalayaproject.activity.OwnerLoginActivity;

/**
 * A simple {@link Fragment} subclass.
 */
public class SubScriptionFragment extends Fragment implements View.OnClickListener {
    private Button button;
    private TextView textView;
    private onIntentRecommendListent listener;

    public SubScriptionFragment() {
        // Required empty public constructor
    }

    public onIntentRecommendListent getListener() {
        return listener;
    }

    public void setListener(onIntentRecommendListent listener) {
        this.listener = listener;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_sub_scription, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        aboutInit(view);
    }

    private void aboutInit(View view) {
        button = (Button) view.findViewById(R.id.fragment_sub_scription_look_but);
        textView = (TextView) view.findViewById(R.id.fragment_sub_scription_login);
        button.setOnClickListener(this);
        textView.setOnClickListener(this);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.fragment_sub_scription_look_but:
                listener.onIntentRecommend();
                break;
            case R.id.fragment_sub_scription_login:
                Intent intent = new Intent(getContext(), OwnerLoginActivity.class);
                startActivity(intent);
                break;
        }
    }

    public interface onIntentRecommendListent {
        void onIntentRecommend();
    }

}
